import type { AdColumn } from '@/components/AdVxeTable';

import { h } from 'vue';

import { useI18n } from '@/hooks/web/useI18n';
import { Input } from 'ant-design-vue';

const { t } = useI18n();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 180,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('report.route.print.printLog.printIdTitle'),
    field: 'PrintId',
    width: 180,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'Template.Print.Id',
    dataType: 'integer',
  },
  {
    title: t('report.route.print.printLog.printCodeTitle'),
    field: 'PrintCode',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'Template.Print.PrintCode',
    dataType: 'string',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('report.route.print.printLog.printNameTitle'),
    field: 'PrintName',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'Print.Name',
    dataType: 'string',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('report.route.print.printLog.templateIdTitle'),
    field: 'TemplateId',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('report.route.print.printLog.templateNameTitle'),
    field: 'TemplateName',
    width: 250,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'Template.TemplateName',
    dataType: 'string',
  },
  {
    title: t('report.route.print.printLog.keyTitle'),
    field: 'Key',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('report.route.print.printLog.valueTitle'),
    field: 'Value',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('report.route.print.printLog.argumentsTitle'),
    field: 'Arguments',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
      render: ({ model, field }) => {
        return h(Input.TextArea, {
          value: JSON.stringify(model[field]),
          disabled: true,
        });
      },
    },
  },
  {
    title: t('report.route.print.printLog.userIdTitle'),
    field: 'UserId',
    width: 0,
    visible: false,
    formVisible: false,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('report.route.print.printLog.userNameTitle'),
    field: 'UserName',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UserId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('report.route.print.printLog.userNicknameTitle'),
    field: 'UserNickname',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UserId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.creatorIdTitle'),
    field: 'CreatorId',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('entity.creationAudited.createdTimeTitle'),
    field: 'CreatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
];
